/* 
 * Shuriken is the legal property of its developers. Please refer to the
 * COPYRIGHT file distributed with this
 * source distribution.
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

using System;
using System.Collections.Generic;
using System.Text;
using Shuriken.Core.Shell; 

namespace Shuriken.Core.Store.Scanners
{
    /// <summary>
    /// Scanning shell folders
    /// </summary>
    public class ShellScannerHelper
    {
        private List<ShellAPI.CSIDL> m_Locations;
        private List<string> m_Pattern;
        private bool m_Recursive;

        private Shuriken.Core.Shell.ShellManager manager;

        public ShellScannerHelper()
        {
            manager = Shuriken.Core.Shell.ShellManager.Instance;

            List<ShellItem> cpList = manager.GetShellItemsList(ShellAPI.CSIDL.CSIDL_CONTROLS, false);
        }

        #region Properties
        /// <summary>
        /// Pattern for scanning files
        /// </summary>
        public List<string> Pattern
        {
            get { return m_Pattern; }
            set { m_Pattern = value; }
        }

        /// <summary>
        /// Locations to scan
        /// </summary>
        public List<ShellAPI.CSIDL> Locations
        {
            get { return m_Locations; }
            set { m_Locations = value; }
        }

        /// <summary>
        /// True, if recursive scanning is needed.
        /// </summary>
        public bool Recursive
        {
            get { return m_Recursive; }
            set { m_Recursive = value; }
        }
        #endregion

        public List<ShellItem> Scan()
        {
            List<ShellItem> list = new List<ShellItem>();
            
            foreach (ShellAPI.CSIDL location in m_Locations)
            {
                list.AddRange(manager.GetShellItemsList(location, m_Recursive));
            }

            return list;
        }

    }
}
